<template>
  <a-form
    @submit="handleSubmit"
    :model="form"
    class="form"
    :rules="rules"
    ref="taskForm"
    :labelCol="formItemLayout.labelCol"
    :wrapperCol="formItemLayout.wrapperCol"

  >


    <a-row class="form-row" :gutter="16" >
      <a-col :lg="6" :md="12" :sm="24" >
        <a-form-item label="姓名" name="name2">
          <a-input placeholder="请输入姓名" v-model:value="form.name2" />
        </a-form-item>
      </a-col>
      <a-col :xl="{span: 6, offset: 1}" :lg="{span: 8}" :md="{span: 12}" :sm="24" >
        <a-form-item label="学号" name="url2">
          <a-input placeholder="请输入学号" v-model:value="form.url2" />
        </a-form-item>
      </a-col>
      <a-col  :xl="{span: 6, offset: 4}" :lg="{span: 8}" :md="{span: 12}" :sm="24">
        <a-button type="primary" html-type="submit">
          查询
        </a-button>
        <a-button :style="{ marginLeft: '8px' }" @click="handleReset">
          重置
        </a-button>
        <a :style="{ marginLeft: '8px', fontSize: '12px' }" @click="toggle">
          展开 <a-icon :type="expand ? 'up' : 'down'" />
        </a>
      </a-col>
    </a-row>






    <a-row class="form-row" :gutter="16" v-if="expand">
      <a-col :lg="6" :md="12" :sm="24" >
        <a-form-item label="班级" name="approver2" >
          <a-input placeholder="请输入班级" v-model:value="form.approver2" />
        </a-form-item>
      </a-col>
      <a-col :xl="{span: 6, offset: 1}" :lg="{span: 12}" :md="{span: 24}" :sm="24" >
        <a-form-item label="性别" name="type2">
          <a-select placeholder="请性别" v-model:value="form.type2">
            <a-select-option value="男">男</a-select-option>
            <a-select-option value="女">女</a-select-option>
          </a-select>
        </a-form-item>
      </a-col>
    </a-row>




    <a-form-item v-if="showSubmit">
      <a-button htmlType="submit" >Submit</a-button>
    </a-form-item>
  </a-form>

</template>

<script>
  import {Form, Button, Input, TimePicker, Select, Row, Col, Icon} from 'ant-design-vue';
  const FormItem = Form.Item;
  const { Option } = Select;
  export default {
    name: 'TaskForm',
    components: {
      AIcon:Icon,
      ARow: Row,
      ACol: Col,
      AForm: Form,
      AButton: Button,
      AInput: Input,
      ATimePicker: TimePicker,
      AFormItem: FormItem,
      ASelect: Select,
      ASelectOption: Option,
    },
    props: {
      showSubmit: {
        type: Boolean,
        default: false
      }
    },
    data () {
      return {
        expand: false,
        form: {
          name2: '',
          url2: '',
          owner2: '',
          approver2: '',
          dateRange2: null,
          type2: '',
        },
        formItemLayout: {
          labelCol: {
            xs: { span: 24 },
            sm: { span: 8 },
          },
          wrapperCol: {
            xs: { span: 24 },
            sm: { span: 16 },
          }
        },
        rules: {
          name2: [{ required: true, message: '请输入姓名', whitespace: true}],
          url2: [{ required: true, message: '请输入学号', whitespace: true}],
          approver2: [{ required: true, message: '请选择班级'}],
          type2: [{ required: true, message: '请选择性别'}]
        },
      }
    },

    methods: {
      handleSubmit (e) {
        e.preventDefault();
        this.$refs.taskForm.validateFields().then(() => {
          this.$notification['error']({
            message: 'Received values of form:',
            description: this.form
          })
        })
      },

      handleReset() {
        this.form.resetFields();
      },
      toggle() {
        this.expand = !this.expand;
      },

    },

  }
</script>

<style scoped>

</style>
